
;(function ($) {

    // Constructor
    function FT(elem) {
        this.$textarea = $(elem);

        this._init();
    }

    FT.prototype = {
        _init: function () {
            var _this = this;

            // Insert wrapper elem & pre/span for textarea mirroring
            this.$textarea.wrap('<div class="flex-text-wrap" />').before('<pre class="pre"><span /><br /></pre>');

            this.$span = this.$textarea.prev().find('span');

            // Add input event listeners
            // * input for modern browsers
            // * propertychange for IE 7 & 8
            // * keyup for IE >= 9: catches keyboard-triggered undos/cuts/deletes
            // * change for IE >= 9: catches mouse-triggered undos/cuts/deletions (when textarea loses focus)
            this.$textarea.on('input propertychange keyup change', function () {
                _this._mirror();
            });

            // jQuery val() strips carriage return chars by default (see http://api.jquery.com/val/)
            // This causes issues in IE7, but a valHook can be used to preserve these chars
            $.valHooks.textarea = {
                get: function (elem) {
                    return elem.value.replace(/\r?\n/g, "\r\n");
                }
            };

            // Mirror contents once on init
            this._mirror();
        }

        // Mirror pre/span & textarea contents
        ,_mirror: function () {
            this.$span.text(this.$textarea.val());
        }
    };

    // jQuery plugin wrapper
    $.fn.flexText = function () {
        return this.each(function () {
            // Check if already instantiated on this elem
            if (!$.data(this, 'flexText')) {
                // Instantiate & store elem + string
                $.data(this, 'flexText', new FT(this));
            }
        });
    };

})(jQuery);

$(function () {
    $.ajax({
        type: 'post',
        url:'/dev/user/comment',

        success:function (result){
            console.log(result)

            let data=result.data;
            // 获取所有的图片占位符
            // const placeholders = content.match(/\{img\}/g);

            for (let i = 0; i < data.length; i++) {

                str = `
                <div class="comment-show-con clearfix">
    <div class="comment-show-con-img pull-left"><img src="img/ico.jpg" alt=""></div>
    <div class="comment-show-con-list pull-left clearfix">
        <div class="pl-text clearfix">
            <a href="#" class="comment-size-name">${data[i].fromName} : </a>
            <span class="my-pl-con">&nbsp;${data[i].content} </span>
        </div>
        <div class="date-dz">
            <span class="date-dz-left pull-left comment-time">${data[i].createTime} </span>
            <div class="date-dz-right pull-right comment-pl-block">
                <a href="javascript:;" class="removeBlock">删除</a>
                <a href="javascript:;" class="date-dz-pl pl-hf hf-con-block pull-left">回复</a>
                <span class="pull-left date-dz-line">|</span>
                <a href="javascript:;" class="date-dz-z pull-left"><i class="date-dz-z-click-red"></i>赞 (<i class="z-num">666</i>)</a>
            </div>
        </div>
        <div class="hf-list-con"></div>
    </div>
</div>
</div>

                <br>`;

                $('.comment-show').append(str);

            }




        }

    })
})



